/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2023-11-01
 * Time: 22:43
 */
    //n==1直接将pos1移到pos3上
    //n!=1通过pos3为中间媒介将pos1移到pos2上。
    //然后在通过pos1为媒介将pos2移到pos3上
public class Test {
    //移动方法
    public static void move(char pos1,char pos2) {
        System.out.print(pos1+"->"+pos2+" ");
    }
    //主要方法
    public static void hanoi(int n,char pos1,char pos2,char pos3) {
        if(n == 1){
            move(pos1,pos3);
            return;
        }
        hanoi(n-1,pos1,pos3,pos2);
        move(pos1,pos3);
        hanoi(n-1,pos2,pos1,pos3);
    }
    public static void main(String[] args) {
        hanoi(3,'A','B','C');
    }
}
